package org.springframework.samples.petclinic.web;

import java.util.Collection;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.samples.petclinic.Clinic;
import org.springframework.samples.petclinic.Owner;
import org.springframework.samples.petclinic.Vet;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service

public class ChuckService {
	private Clinic clinic;
	
	@Autowired
	public void setClinic(Clinic clinic){
		this.clinic = clinic;
	}
	
	public void toConsole(String str){
		System.out.println(str);
	}
	
	@Transactional
	public void storeOwner(Owner owner){
		Collection<Owner> ownersWithSameLastName = clinic.findOwnersChuck(owner.getLastName());
		System.out.println("number of owners with same last name is " + ownersWithSameLastName.size());
		clinic.storeOwner(owner);
	}
	
}
